#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
    int a,b,c;
    cin >> a >> b;
    while(true){
        if (max(a,b) % min(a,b) == 0){
            c = min(a,b);
            break;
        }
        else{
            if (max(a,b) == a){
                a = a % b;
            }
            else{
                b = b % a;
            }
        }
    }
    cout << c;
    return 0;
}